﻿using HKB.Common;
using HKB.Web;
using HKB.Web.Admin;
using System;
using System.Web.Profile;
using System.Web.SessionState;
using System.Web.UI.WebControls;

public partial class Admin_Admin_ShopManageModule : Admin, IRequiresSessionState
{
    private Shop_Module _module = null;
    protected Shop_Module module
    {
        get
        {
            Shop_Module module;
            if (this._module == null)
            {
                this._module = new Shop_Module(this.conn);
                module = this._module;
            }
            else
            {
                module = this._module;
            }
            return module;
        }
    }
    protected DefaultProfile profile
    {
        get
        {
            return (DefaultProfile)this.Context.Profile;
        }
    }
    protected global_asax applicationInstance
    {
        get
        {
            return (global_asax)this.Context.ApplicationInstance;
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!base.admin.CheckAdminPower(10))
        {
            base.WriteLog("View", Language.GetAdminMsg("Log/Access", "0"), "ArticleModule");
            base.WriteRightErrMsg();
        }
        this.BindList();
    }
    private void BindList()
    {
        this.GridView1.DataSource = this.module.GetAllModule();
        this.GridView1.DataBind();
    }
    protected void GridView1_DataBound(object sender, EventArgs e)
    {
        bool flag = base.admin.CheckAdminPower(10);
        bool flag2 = base.admin.CheckAdminPower(10);
        foreach (GridViewRow gridViewRow in this.GridView1.Rows)
        {
            LinkButton linkButton = (LinkButton)gridViewRow.FindControl("LinkButton1");
            if (!flag2)
            {
                if (linkButton != null)
                {
                    linkButton.Enabled = false;
                }
            }
            if (!flag)
            {
                HyperLink hyperLink = (HyperLink)gridViewRow.FindControl("modifybutton");
                if (hyperLink != null)
                {
                    hyperLink.Enabled = false;
                }
            }
            if (gridViewRow.Cells[3].Text == "1")
            {
                gridViewRow.Cells[3].Text = "启用";
            }
            else
            {
                gridViewRow.Cells[3].Text = "禁用";
            }
        }
    }
    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        e.Row.Attributes.Add("onmouseover", "c=this.style.backgroundColor;this.style.backgroundColor='#E7EDFE'");
        e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=c;");
    }
    protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        this.GridView1.PageIndex = e.NewPageIndex;
        this.BindList();
    }
    protected void Delete_OnClick(object sender, CommandEventArgs e)
    {
        if (e.CommandArgument != null)
        {
            int num = Convert.ToInt32(e.CommandArgument.ToString());
            int num2 = this.conn.ExecuteCount("Select count(ArticleID) from [HLShop_IndexArticle] Where ChannelID=" + num);
            if (num2 > 0)
            {
                this.WriteErrMsg("", string.Concat(new object[]
				{
					"该",
					Language.GetAdminMsg("Article/ChannelTitle"),
					"下有",
					num2,
					Language.GetAdminMsg("Article/Unit"),
					Language.GetAdminMsg("Article/Title"),
					",请先将其移除。"
				}), "Admin_ShopIndexArticle.aspx?ModuleID=" + num);
            }
            else
            {
                this.module.DelModule(num);
                this.BindList();
            }
        }
    }
}
